import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerPicture {
    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        Socket socket = null;
        OutputStream outputStream = null;
        FileInputStream fileInputStream = null;

        File file = new File("D:\\githomework\\java1228\\student\\zhaofh\\HomeWork\\the_joker.jpg");
        try {
            serverSocket = new ServerSocket(9900);
            socket = serverSocket.accept();
            outputStream = socket.getOutputStream();
            fileInputStream = new FileInputStream(file);

            byte[] p = new byte[512];
            int length = fileInputStream.read(p);
            while (length != -1) {
                outputStream.write(p, 0, length);
                length = fileInputStream.read(p);
            }
            socket.shutdownOutput();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
